#以高斯混淆算法为例
import numpy as np

def Gaussian_module(y,mu, sigma):
    phi = np.exp(-(y-mu)**2/(2*sigma**2)) / ((2*np.pi*sigma**2)**(1/2))
    return phi

num_module = 3#模型数
gaussian_para = np.random.rand(3,num_module)
y = np.loadtxt('data.csv', delimiter=',')
num_x = 100
gamma = np.zeros([num_x, num_module])
for i in range(100):
    phi = Gaussian_module(y,gaussian_para[0,:],gaussian_para[1,:])
    gamma = gaussian_para[2,:] * phi / np.dot(phi,gaussian_para[2,:].T)

    gaussian_para[0,:] = np.dot(y.T,phi) / np.dot(np.ones([1,num_x]),gamma)
    gaussian_para[1,:] = np.dot((y.T-gaussian_para[0,:])*(y.T-gaussian_para[0,:]),phi) / np.dot(np.ones([1,num_module]),gamma)
    gaussian_para[2,:] = np.dot(np.ones([1,num_module]),gamma) / num_x

